/**
 * 
 */
package com.bot.service;

import java.util.List;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bot.mapper.ApplicantMapper;
import com.bot.pojo.Applicant;
import com.bot.pojo.Job;
import com.bot.pojo.Score;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * @author zhaoyan
 *
 * 2020年2月3日
 */
@Service
public class ApplicantServiceImpl implements ApplicantService{

	@Autowired
	private ApplicantMapper applicantMapper; 
	
	@Override
	public PageInfo<Applicant> findApplicantByCon(Integer pageNum, Integer flag) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum, 3);
		return new PageInfo<Applicant>(applicantMapper.findApplicantList(flag));
	}

	@Override
	public Integer addApplicant(Applicant applicant) {
		// TODO Auto-generated method stub
		return applicantMapper.addApplicant(applicant);
	}

	@Override
	public Applicant findApplicantById(Integer aid) {
		// TODO Auto-generated method stub
		return applicantMapper.findApplicant(aid);
	}

	@Override
	public List<Job> findJobList() {
		// TODO Auto-generated method stub
		return applicantMapper.findJonList();
	}

	@Override
	public Integer addScore(@Valid Score score) {
		// TODO Auto-generated method stub
		return applicantMapper.addScore(score);
	}

	@Override
	public Integer delApp(Integer id) {
		// TODO Auto-generated method stub
		
		Integer num = applicantMapper.delApp(id);

		if(num > 0) {
			
			applicantMapper.delScore(id);
		}
		
		return num;
	}

}
